package com.cmc.cloud.cmclink.doc.controller.admin.si;

import com.cmc.cloud.cmclink.doc.service.si.BlnoSpiltCombineDetailService;
import com.cmc.cloud.cmclink.doc.api.document.rep.blnospiltcombinedetailvo.BlnoSpiltCombineDetailCreateReqVO;
import com.cmc.cloud.cmclink.doc.api.document.rep.blnospiltcombinedetailvo.BlnoSpiltCombineDetailPageReqVO;
import com.cmc.cloud.cmclink.doc.api.document.rep.blnospiltcombinedetailvo.BlnoSpiltCombineDetailRespVO;
import com.cmc.cloud.cmclink.doc.api.document.rep.blnospiltcombinedetailvo.BlnoSpiltCombineDetailUpdateReqVO;
import com.cmes.framework.biz.advice.annotations.UseResponsePropertyAdvice;
import com.cmes.framework.operatelog.core.annotations.OperateLog;
import com.cmes.framework.operatelog.core.enums.OperateTypeEnum;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.*;
import java.util.*;

import com.cmc.cloud.cmclink.doc.entity.BlnoSpiltCombineDetailDO;
import com.cmc.cloud.cmclink.doc.convert.BlnoSpiltCombineDetailConvert;

/**
 * 提单拆并申请主前端接口Controller
 * 
 * @author codegen
 */
@Tag(name = "管理后台 - 提单拆并申请详情")
@RestController
@Validated
@RequestMapping("/admin-api/doc/v1/blno-spilt-combine-detail")
public class BlnoSpiltCombineDetailController {

    @Resource
    private BlnoSpiltCombineDetailService blnoSpiltCombineDetailService;

    @Operation(summary = "创建提单拆并申请主")
    @OperateLog(type = OperateTypeEnum.CREATE)
    @PostMapping("/create")
    @PreAuthorize("@ss.hasPermission('doc:blno-spilt-combine-detail:create')")
    public CommonResult<Void>
        createBlnoSpiltCombineDetail(@Valid @RequestBody BlnoSpiltCombineDetailCreateReqVO createReqVO) {
        blnoSpiltCombineDetailService.createBlnoSpiltCombineDetail(createReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "更新提单拆并申请主")
    @OperateLog(type = OperateTypeEnum.UPDATE)
    @PostMapping("/update")
    @PreAuthorize("@ss.hasPermission('doc:blno-spilt-combine-detail:update')")
    public CommonResult<Void>
        updateBlnoSpiltCombineDetail(@Valid @RequestBody BlnoSpiltCombineDetailUpdateReqVO updateReqVO) {
        blnoSpiltCombineDetailService.updateBlnoSpiltCombineDetail(updateReqVO);
        return CommonResult.success();
    }

    @Operation(summary = "删除提单拆并申请主")
    @OperateLog(type = OperateTypeEnum.DELETE)
    @PostMapping("/delete/{id}")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('doc:blno-spilt-combine-detail:delete')")
    public CommonResult<Void> deleteBlnoSpiltCombineDetail(@PathVariable("id") Long id) {
        blnoSpiltCombineDetailService.deleteBlnoSpiltCombineDetail(id);
        return CommonResult.success();
    }

    @Operation(summary = "获得提单拆并申请主")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/get/{id}")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('doc:blno-spilt-combine-detail:query')")
    public CommonResult<BlnoSpiltCombineDetailRespVO> getBlnoSpiltCombineDetail(@PathVariable("id") Long id) {
        BlnoSpiltCombineDetailDO blnoSpiltCombineDetail = blnoSpiltCombineDetailService.getBlnoSpiltCombineDetail(id);
        return CommonResult.success(BlnoSpiltCombineDetailConvert.INSTANCE.convert(blnoSpiltCombineDetail));
    }

    @Operation(summary = "获得提单拆并申请主列表")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/list")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    @PreAuthorize("@ss.hasPermission('doc:blno-spilt-combine-detail:query')")
    public CommonResult<List<BlnoSpiltCombineDetailRespVO>>
        getBlnoSpiltCombineDetailList(@RequestParam("ids") Collection<Long> ids) {
        List<BlnoSpiltCombineDetailDO> list = blnoSpiltCombineDetailService.getBlnoSpiltCombineDetailList(ids);
        return CommonResult.success(BlnoSpiltCombineDetailConvert.INSTANCE.convertList(list));
    }

    @Operation(summary = "获得提单拆并申请主分页")
    @OperateLog(type = OperateTypeEnum.GET)
    @GetMapping("/page")
    @PreAuthorize("@ss.hasPermission('doc:blno-spilt-combine-detail:query')")
    @UseResponsePropertyAdvice
    public CommonResult<PageResult<BlnoSpiltCombineDetailRespVO>>
        getBlnoSpiltCombineDetailPage(@Valid BlnoSpiltCombineDetailPageReqVO pageVO) {
        PageResult<BlnoSpiltCombineDetailDO> pageResult =
            blnoSpiltCombineDetailService.getBlnoSpiltCombineDetailPage(pageVO);
        List<BlnoSpiltCombineDetailRespVO> results =
            BlnoSpiltCombineDetailConvert.INSTANCE.convertList(pageResult.getList());
        return CommonResult.success(new PageResult<>(results, pageResult.getTotal()));
    }
}
